<?php

/* 处理内容管理中的文章分类
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
//连接初始化文件
require dirname(dirname(__FILE__)) . '/include/init.php';
require model('categorys');

//接收动作
$action = $_GET['action'];

if ($action == 'add') {
    $url = 'categorys.php?action=doadd';
    include WEB_ROOT . '/admin/template/menu1_categorys.html.php';
} elseif ($action == 'doadd') {
    //对提交的信息进行处理
    if (isset($_POST['submit'])) {
        add_categorys($_POST['category'], $_POST['content']);
    }
} elseif ($action == 'default') {//显示所有的分类信息
    $categorys = mancate();
    include WEB_ROOT . '/admin/template/menu1_check_categorys.html.php';
} elseif ($action == 'del') {
    $cid = $_GET['cid'];
    confirm_msg('您确定要删除该分类吗?', '/admin/categorys.php?action=dodel&cid=' . $cid . '', '/admin/categorys.php?action=default');
} elseif ($action == 'edit') {
    $cid = $_GET['cid'];
    //调用方法读出数据库中的分类信息
    $cate_info = show_cate($cid);
    //为tpl设置value值
    $url = 'categorys.php?action=doedit&cid=' . $cid . '';
    include WEB_ROOT . '/admin/template/menu1_categorys.html.php';
} elseif ($action == 'doedit') {    
    $cid = $_GET['cid'];
    //对提交的信息进行处理
    if (isset($_POST['submit'])) {
        edit_categorys($_POST['category'], $_POST['content'],$cid);
        
    }
} elseif ($action == 'dodel') {
    $cid = $_GET['cid'];
    del_cate($cid);
}
